<template>
  <div>
    <el-input v-model="cityName"></el-input>
    <el-button @click="getLocationId(cityName)">getcity</el-button>
    <el-button @click="getHotCity">gethotcity</el-button>
    <ul>
      <li v-for="(item,index) in cityList" :key="index">
        <el-button @click="getWeatherThreeDay(item.id)">{{item.name}}</el-button>
        <el-button @click="getIndices(item.id)">shzs</el-button>
        <el-button @click="getHistoryWeather(item.id,20210801)">lstq</el-button>
        <el-button @click="getHistoryAir(item.id,20210801)">lskqzl</el-button>
      </li>
    </ul>
  </div>
</template>

<script>
export default {
  name: 'AxiosTest',
  data () {
    return {
      cityName: '',
      cityList: [],
      cityCode: ''
    }
  },
  mounted () {
    console.log(this)
  },
  methods: {
    getLocationId (cityName) {
      this.$request.getLocationId({ location: cityName }).then(res => {
        this.cityList = res.location
        console.log(res)
      })
    },
    getWeather (id) {
      this.$request.getWeather({ location: id }).then(res => {
        console.log(res)
      })
    },
    getHotCity () {
      this.$request.getHotCity().then(res => {
        console.log(res)
      })
    },
    getWeatherThreeDay (id) {
      this.$request.getWeatherThreeDay({ location: id }).then(res => {
        console.log(res)
      })
    },
    getIndices (id) {
      this.$request.getIndices({ location: id, type: 0 }).then(res => {
        console.log(res)
      })
    },
    getWarning (id) {
      this.$request.getWarning({ location: id }).then(res => {
        console.log(res)
      })
    },
    getWarningCityList () {
      this.$request.getWarningCityList({ range: 'cn' }).then(res => {
        console.log(res)
      })
    },
    getAirQuality (id) {
      this.$request.getAirQuality({ location: id }).then(res => {
        console.log(res)
      })
    },
    getHistoryWeather (id, date) {
      this.$request.getHistoryWeather({ location: id, date: date }).then(res => {
        console.log(res)
      })
    },
    getHistoryAir (id, date) {
      this.$request.getHistoryAir({ location: id, date: date }).then(res => {
        console.log(res)
      })
    }
  }
}
</script>

<style scoped lang="scss">

</style>
